home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0264.ZIP / ZENO.ASM < prev    next >
Assembly Source File  |  1986-06-11  |  12KB  |  340 lines

  1. page 66,132
  2. page
  3. ;  X:0
  4. ;
  5. ; ZENO:  June 11, 1986
  6. ;
  7. cseg    segment para public 'code'
  8. zeno            proc  far
  9.         assume  cs:cseg, ds:cseg, es:cseg, ss:cseg
  10.         org     100h            ; for .COM file
  11. ;
  12. environment     equ   2Ch
  13. command         equ   80h
  14. slashk          equ   'K/'
  15. ;
  16. ;-------------------------------
  17. ; enter here on initial load
  18. ;-------------------------------
  19. ;
  20. start:
  21. ;
  22.         jmp     near ptr load_pgm
  23. ;
  24. video_vector    dd   0
  25. core_seg        dw   0
  26. ;
  27. bios_cursor_posn  label  dword
  28. bios_ofst       dw   00h        ; offset for active page
  29.                 dw   40h        ; segment for bios data
  30.  
  31. ;
  32. crt_mode        db   2          ; passes if 4, 5, or 6
  33. active_page     db   0
  34. cursor_type     dw   0B0Ch      ; DOS cursor
  35. ;
  36. video_posn      label  dword
  37. video_ofst      dw     0        ; offset against video_seg
  38. video_seg       dw     0
  39. ;
  40. video_addr      dw     0
  41. ;
  42. onesixty        db   160
  43. ;
  44. ;-------------------------------
  45. ; enter here from int 10h
  46. ;-------------------------------
  47. ;
  48. video_int:
  49.         sti                     ; interrupts on
  50.         pushf                   ; save flags
  51.         cmp     cs:crt_mode,7   ; check for b/w
  52.         je      video_keep      ; go if b/w
  53.         cmp     cs:crt_mode,4   ; check for graphics
  54.         jnc     video_exit      ; go if graphics
  55. video_keep:
  56.         cmp     ah,2            ; to set cursor
  57.         je      set_cursor
  58.         cmp     ah,10           ; to write char only
  59.         je      write_char
  60.         cmp     ah,9            ; to write char/attr
  61.         je      route_write_both
  62.         cmp     ah,3            ; to read cursor
  63.         je      route_read_cursor
  64.         cmp     ah,1            ; to set type
  65.         je      route_set_type
  66.         cmp     ah,0            ; to set mode
  67.         je      route_set_mode
  68.         cmp     ah,5            ; to set page
  69.         je      route_set_page
  70.         cmp     ax,0FF00h       ; kill code
  71.         je      route_do_kill   ; go if found
  72. video_exit:
  73.         popf                    ; restore flags
  74.         jmp     cs:dword ptr video_vector ; hand off interrupt
  75. ;
  76. route_write_both:
  77.         jmp     write_both
  78. ;
  79. route_read_cursor:
  80.         jmp     read_cursor
  81. ;
  82. route_set_page:
  83.         jmp     set_page
  84. ;
  85. route_set_type:
  86.         jmp     set_type
  87. ;
  88. route_set_mode:
  89.         jmp     set_mode
  90. ;
  91. route_do_kill:
  92.         jmp     do_kill
  93. ;
  94. write_char:
  95.         cmp     bh,cs:active_page ; check page
  96.         jne     video_exit      ; pass to bios
  97.         cmp     cx,1            ; for multiple write
  98.         jne     video_exit      ; pass to bios
  99.         push    di              ; save
  100.         push    es              ; save
  101.         les     di,cs:video_posn ; get screen position
  102.         cld                     ; frontwards
  103.         stosb                   ; dump to screen
  104.         pop     es              ; restore
  105.         pop     di              ; restore
  106.         popf                    ; restore flags
  107.         iret                    ; done
  108. ;
  109. set_cursor:
  110.         cmp     bh,cs:active_page ; check page
  111.         jne     video_exit      ; pass to bios
  112.         push    ax              ; save
  113.         push    cx              ; save
  114.         push    dx              ; save
  115.         push    di              ; save
  116.         push    es              ; save
  117.         add     cs:video_ofst,2 ; for next char
  118.         les     di,cs:bios_cursor_posn ; get bios
  119.         inc     byte ptr es:[di] ; assume next
  120.         cmp     es:[di],dx      ; check if next
  121.         je      offset_ready    ; go if next
  122.         mov     ax,dx           ; get req posn
  123.         mov     es:[di],ax      ; save req posn
  124.         mov     cx,ax           ; copy posn
  125.         mov     al,ah           ; rows in al
  126.         mul     cs:onesixty     ; for bytes
  127.         xor     ch,ch           ; cols in cx
  128.         shl     cx,1            ; for video
  129.         add     ax,cx           ; offset in ax
  130.         mov     cs:video_ofst,ax ; store offset
  131. offset_ready:
  132.         mov     cx,cs:video_ofst ; offset in cx
  133.         shr     cx,1            ; for byte count
  134.         mov     ah,14           ; cursor MSB register
  135.         mov     dx,cs:video_addr ; 6845 index addr
  136.         mov     al,ah           ; get register
  137.         out     dx,al           ; send register
  138.         inc     dx              ; 6845 data addr
  139.         mov     al,ch           ; get cursor MSB
  140.         out     dx,al           ; send cursor MSB
  141.         dec     dx              ; 6845 index addr
  142.         mov     al,ah           ; cursor MSB register
  143.         inc     al              ; cursor LSB register
  144.         out     dx,al           ; send register
  145.         inc     dx              ; 6845 data addr
  146.         mov     al,cl           ; get cursor LSB
  147.         out     dx,al           ; send cursor LSB
  148.         pop     es              ; restore
  149.         pop     di              ; restore
  150.         pop     dx              ; restore
  151.         pop     cx              ; restore
  152.         pop     ax              ; restore
  153.         popf                    ; restore flags
  154.         iret                    ; done
  155. ;
  156. route_video_exit:
  157.         jmp     video_exit
  158. ;
  159. write_both:
  160.         cmp     bh,cs:active_page ; check page
  161.         jne     route_video_exit ; pass to bios
  162.         cmp     cx,1            ; check multiple write
  163.         jne     route_video_exit ; pass to bios
  164.         push    ax              ; save
  165.         push    di              ; save
  166.         push    es              ; save
  167.         mov     ah,bl           ; get attribute
  168.         les     di,cs:video_posn ; get screen position
  169.         cld                     ; frontwards
  170.         stosw                   ; dump to screen
  171.         pop     es              ; restore
  172.         pop     di              ; restore
  173.         pop     ax              ; restore
  174.         popf                    ; restore flags
  175.         iret                    ; done
  176. ;
  177. read_cursor:
  178.         cmp     bh,cs:active_page ; check page
  179.         jne     route_video_exit ; pass to bios
  180.         push    di              ; save
  181.         push    es              ; save
  182.         les     di,cs:bios_cursor_posn ; get bios
  183.         mov     dx,es:[di]      ; get bios posn
  184.         mov     cx,cs:cursor_type ; get type
  185.         pop     es              ; restore
  186.         pop     di              ; restore
  187.         popf                    ; restore flags
  188.         iret                    ; done
  189. ;
  190. set_page:
  191.         push    ax              ; save
  192.         mov     cs:active_page,al ; save page
  193.         xor     ah,ah           ; page in ax
  194.         shl     ax,1            ; for word count
  195.         add     ax,50h          ; offset for page zero
  196.         mov     cs:bios_ofst,ax ; save offset
  197.         pop     ax              ; restore
  198.         jmp     video_exit      ; pass to bios
  199. ;
  200. set_type:
  201.         mov     cs:cursor_type,cx ; save type
  202.         jmp     video_exit      ; pass to bios
  203. ;
  204. set_mode:
  205.         mov     cs:crt_mode,al  ; save mode
  206.         mov     cs:video_ofst,0 ; top left
  207.         jmp     video_exit      ; done
  208. ;
  209. ; remove routine from memory
  210. ;
  211. do_kill:
  212.         mov     ax,cs           ; get code segment
  213.         mov     ds,ax           ; set data segment
  214.         mov     es,ax           ; set extra segment
  215.         push    ds              ; save
  216.         mov     ax,2510h        ; to set video vector
  217.         lds     dx,video_vector ; get original
  218.         int     21h             ; set vector
  219.         pop     ds              ; restore
  220.         mov     ah,49h          ; for free memory fn
  221.         int     21h             ; do free memory
  222.         push    es              ; save
  223.         mov     bx,environment  ; get env. segment
  224.         mov     es,cs:[bx]
  225.         mov     ah,49h          ; for free memory fn
  226.         int     21h             ; do free memory
  227.         pop     es              ; restore
  228.         lea     dx,kill_msg     ; get message
  229.         mov     ah,9            ; for screen write
  230.         int     21h             ; do write
  231.         popf                    ; restore flags
  232.         iret                    ; return to ZENO/K
  233. ;
  234. kill_msg        db   13,10,'ZENO Removed',13,10,'$'
  235. ;
  236. end_core:
  237. ;
  238. ;-------------------------------
  239. ; enter here to load program   
  240. ;-------------------------------
  241. ;
  242. load_pgm:
  243. ;
  244. ; check for color screen; set video segment
  245. ;
  246.         mov     video_seg,0B000h ; assume mono
  247.         mov     video_addr,03B4h ; assume mono
  248.         int     11h             ; for equip check
  249.         and     ax,30h          ; isolate adapter
  250.         cmp     ax,30h          ; check for mono
  251.         je      mono_screen     ; go if found
  252.         mov     video_seg,0B800h ; reset for color
  253.         mov     video_addr,03D4h ; reset for color
  254. mono_screen:
  255. ;
  256. ; check command line
  257. ;
  258.         mov     si,command      ; get command line
  259.         mov     al,cs:[si]      ; length of argument
  260.         or      al,al           ; check for zero
  261.         je      command_clear   ; go if zero
  262.         cmp     al,2            ; for kill request
  263.         jne     retry           ; go if not
  264.         cmp     word ptr cs:[si+1],slashk ; check for '/K'
  265.         jne     retry           ; go if not
  266.         mov     ax,0FF00h       ; set for kill
  267.         int     10h             ; order kill
  268.         int     20h             ; exit to DOS
  269. retry:
  270.         lea     dx,retry_msg    ; get message
  271.         mov     ah,9            ; for print fn
  272.         int     21h             ; print message
  273.         int     20h             ; exit to DOS
  274. command_clear:
  275. ;
  276. ; find and set current variables
  277. ;
  278.         les     di,bios_cursor_posn ; set to 0040:0000
  279.         mov     al,es:[di+49h]  ; get current mode
  280.         mov     crt_mode,al     ; save mode
  281.         mov     ax,es:[di+60h]  ; get cursor type
  282.         mov     cursor_type,ax  ; save type
  283.         mov     al,es:[di+62h]  ; get active page
  284.         mov     active_page,al  ; save active page
  285.         xor     ah,ah           ; page in ax
  286.         shl     ax,1            ; for word count
  287.         add     ax,50h          ; offset for page zero
  288.         mov     bios_ofst,ax    ; save offset
  289. ;
  290. ; set video interrupt
  291. ;
  292.         mov     core_seg,cs     ; set core segment
  293.         push    es              ; save
  294.         mov     ax,3510h        ; to get vector
  295.         int     21h             ; get vector
  296.         mov     video_vector,bx ; store offset
  297.         mov     video_vector+2,es ; store segment
  298.         pop     es              ; restore
  299.         mov     ax,2510h        ; to set video vector
  300.         lea     dx,video_int    ; get offset; ds OK
  301.         int     21h             ; set vector
  302. ;
  303. ; print messages; terminate and stay resident
  304. ;
  305.         lea     dx,install_msg  ; get message
  306.         mov     ah,9h           ; for print fn
  307.         int     21h             ; print message
  308.         cmp     video_seg,0B000h ; check for mono
  309.         je      skip_message    ; go if mono
  310.         lea     dx,color_msg    ; get message
  311.         mov     ah,9h           ; for print fn
  312.         int     21h             ; print message
  313. skip_message:
  314.         lea     dx,finish_msg   ; get termination
  315.         mov     ah,9h           ; for print fn
  316.         int     21h             ; print ternination
  317.         lea     ax,end_core     ; last address in core
  318.         add     ax,2Fh          ; make bumper
  319.         mov     cl,4            ; for shift
  320.         shr     ax,cl           ; convert to paras
  321.         mov     bx,ax           ; no. paras to keep
  322.         mov     dx,ax           ; same
  323.         mov     ah,4Ah          ; for setblock
  324.         int     21h             ; do setblock
  325.         mov     ax,3100h        ; for keep; no exit code
  326.         int     21h             ; exit and stay resident
  327. ;
  328. install_msg     db   13,10,'ZENO Successfully Installed$'
  329. ;
  330. color_msg       db   ';',13,10,'May Cause Interference.$'
  331. ;
  332. finish_msg      db   13,10,'$'
  333. ;
  334. retry_msg       db   13,10,'No Action:  Invalid Command Line',13,10,7,'$'
  335. ;
  336. zeno            endp
  337. cseg            ends
  338.         end     start
  339.  
  340.